from interrogate import interrogate_blue
from flask import request, jsonify, render_template, redirect, url_for, session, flash, g, current_app
from sqlalchemy import text
from database.database import User,Interrogate,db
import json
from datetime import datetime

# 问诊主模块（ai）
@interrogate_blue.route('/<word>', methods=['GET'])
def interrogate(word):
    # 获取user_id逻辑区域

    user_id = 1
    # 获取ai回答逻辑区域

    response_ai = "你的语句 "+word+" 已经收到，这是测试的返回"
    # 插入Interrogate表逻辑区域
    interrogate = Interrogate(user_id=user_id,question=word,answer=response_ai,post_time=datetime.now())
    db.session.add(interrogate)
    db.session.commit()

    return jsonify({'code': 200, 'msg': 'success', 'data': response_ai})


